knitr::opts_chunk$set(
echo = TRUE,
error = FALSE,
message = FALSE,
warning = FALSE
)
library(afex)
library(tidyverse)
library(kableExtra)
library(knitr)
library(plotly)
library(broom)
library(wesanderson)
library(robust)
library(ggparl)
library(mediation)
set.seed(2022)# reads excel data sheet
data <- read.csv("../data/study4.csv") # reads data
data_sat <- read.csv("../data/raw/stage3_satisfaction.csv") # reads in satisfaction data
# summary(data) # explore the data types, missing data and typos
data <- data %>%
mutate(gender = ifelse(gender == "m", "m", "f")) # corrects an issuewith extra space in "f "
data$gender <- as.factor(data$gender)
data$pp_number <- as.factor(data$pp_number)
data$condition <-as.factor(data$condition)
# mood data
mood1 <- read.csv("../data/raw/stage1_mood.csv") %>%
dplyr::select(subject, stimulusitem2, response)%>%
rename(response1=response, feeling = stimulusitem2)%>%
mutate(stage = 1)
mood2 <- read.csv("../data/raw/stage2_mood.csv") %>%
dplyr::select(subject, stimulusitem2, response)%>%
rename(response2=response, feeling = stimulusitem2)%>%
mutate(stage = 2)
mood3 <- read.csv("../data/raw/stage3_mood.csv") %>%
dplyr::select(subject, stimulusitem2, response) %>%
rename(response3=response, feeling = stimulusitem2)%>%
mutate(stage = 3)
# qualtrics data
#mainly info about drinking
data_q<- read.csv("../data/other/study_4Q.csv")%>%
dplyr::select(Q21, gender, age, Q15, Q16)%>%
rename(subject = Q21,
units = Q15,
units_beer = Q16)%>%
mutate(subject = as.numeric(subject),
condition = subject %/% 1000)%>%
filter(!is.na(subject))%>%
mutate(subject = as.factor(subject),
gender=as.factor(gender),
age = as.numeric(age),
units = as.numeric(units),
units_beer = as.numeric(units_beer))%>%
filter( subject != "6666")
# expectations & perception of taste/flavour
taste_dat <- read.csv("../data/raw/stage1_perception.csv")%>%
dplyr::select(subject, trialcode, response)%>%
rename(Epercept = trialcode, expected = response)
taste_dat$Epercept<- as.factor(taste_dat$Epercept)
expect_dat<- read.csv("../data/raw/stage1_expectations.csv")%>%
dplyr::select(subject, trialcode, response, stimulusitem3)%>%
filter(stimulusitem3 == "extremely")%>%
dplyr::select(- stimulusitem3)%>%
rename(percept = trialcode, perceived = response)
expect_dat$percept<- as.factor(expect_dat$percept)
# satisfaction data
#merge data_sat and expect_dat
satis_datP <- data_sat %>%
dplyr::select(subject, trialcode, response)%>%
dplyr::filter(trialcode == "VAS")
satis_datE <- expect_dat %>%
dplyr::filter(percept == "VAS_satisE_VAS")
wtp_dat <- data_sat %>%
filter(trialcode == "VAS_wtp")%>%
dplyr::select(subject, response)
# ITT data
itt_s1 <-read.csv("../data/summaries/stage1_ITT.csv")%>%
dplyr::select(script.subjectid, expressions.propcorrect_stim1:expressions.propcorrect_stim13)%>%
mutate(stage1 = 1)%>%
rename(subject = script.subjectid)%>%
rename_at(vars(matches("^expressions")), ~ str_remove(.,"^expressions.propcorrect_")) %>%
pivot_longer(cols = starts_with("stim") ,
names_to = "stimulus" ,
values_to = "correct")
itt_s2 <-read.csv("../data/summaries/stage2_ITT.csv")%>%
dplyr::select(script.subjectid, expressions.propcorrect_stim1:expressions.propcorrect_stim13)%>%
mutate(stage2 = 2)%>%
rename(subject = script.subjectid)%>%
rename_at(vars(matches("^expressions")), ~ str_remove(.,"^expressions.propcorrect_"))%>%
pivot_longer(cols = starts_with("stim") ,
names_to = "stimulus" ,
values_to = "correct")
itt_s3 <-read.csv("../data/summaries/stage3_ITT.csv")%>%
dplyr::select(script.subjectid, expressions.propcorrect_stim1:expressions.propcorrect_stim13)%>%
mutate(stage3 = 3)%>%
rename(subject = script.subjectid)%>%
rename_at(vars(matches("^expressions")), ~ str_remove(.,"^expressions.propcorrect_"))%>%
pivot_longer(cols = starts_with("stim") ,
names_to = "stimulus" ,
values_to = "correct")
itt_dat <- inner_join(itt_s1, itt_s2,
by = c("subject","stimulus"),
keep = FALSE,
suffix = c(".1", ".2"))%>%
inner_join(., itt_s3,
by = c("subject", "stimulus"),
keep = FALSE) %>%
pivot_longer(cols = starts_with("correct") ,
names_to = "stage",
values_to = "correct")%>%
dplyr::select(-c( stage1, stage2, stage3))%>%
mutate( stage = case_when(stage == "correct.1" ~ 'stage 1',
stage == "correct.2" ~ "stage 2",
stage == "correct" ~ "stage 3"))%>%
mutate(condition = subject %/% 1000) %>%
mutate(alcohol = if_else((condition%%2)==1, "alcoholic", "non-alcoholic"))%>%
mutate(focus = case_when(condition == 1 ~ 'control',
condition == 2 ~ 'control',
condition == 3 ~ 'hedonic',
condition == 4 ~ 'hedonic',
condition == 5 ~ 'utilitarian',
condition == 6 ~ 'utilitarian'))DA <- data %>%
dplyr::select(pp_number, BMI)%>%
rename(subject = pp_number)
DB <- data_sat %>%
dplyr::select(subject, response, trialcode ) %>%
mutate(row = row_number(), subject = as.factor(subject)) %>%
pivot_wider(names_from = trialcode, values_from = response) %>%
rename( wtp = VAS_wtp)%>%
dplyr::select(- row)
D1 <- inner_join( DA,DB,
by = "subject",
keep = FALSE
) %>%
pivot_longer(cols =c(VAS, wtp) ,
names_to = "measure",
values_to = "rating") %>%
inner_join(., data_q,
by = "subject",
keep = FALSE)%>%
filter(!is.na(rating))
# long dataset incl,. info about satisfaction and willingness to pay by condition, and alcohol/ non-alcohol
# need to add focus condition
#Joining mood data
D2 <- inner_join(mood1, mood2,
by = c("subject", "feeling"),
keep = FALSE) %>%
inner_join(., mood3,
by = c("subject","feeling"),
keep = FALSE)%>%
dplyr::select(- starts_with("stage")) %>%
mutate(condition = subject %/% 1000) %>%
pivot_longer(cols = starts_with("response"),
names_to = "stage",
names_prefix = "response",
values_to = "rating")
D3_dat <- inner_join(expect_dat, taste_dat,
by = "subject",
keep = FALSE)%>%
mutate(condition = subject %/% 1000) %>%
pivot_wider(names_from = percept,
values_from = perceived) %>%
pivot_wider(names_from = Epercept,
values_from = expected)%>%
rename_at(vars(matches("^VAS\\_")), ~ str_remove(.,"^VAS\\_"))%>%
rename_at(vars(matches("_VAS")), ~ str_remove(.,"_VAS")) %>%
mutate(alcohol = if_else((condition%%2)==1, "alcoholic", "non-alcoholic"))%>%
mutate(focus = case_when(condition == 1 ~ 'control',
condition == 2 ~ 'control',
condition == 3 ~ 'hedonic',
condition == 4 ~ 'hedonic',
condition == 5 ~ 'utilitarian',
condition == 6 ~ 'utilitarian'))
D3_dat$alcohol<- as.factor(D3_dat$alcohol)
D3_dat$focus<- as.factor(D3_dat$focus)
D3_dat$condition <- as.factor(D3_dat$condition)
satis_dat <- inner_join(satis_datE, satis_datP,
by = "subject",
keep = FALSE)%>%
dplyr::select(subject, perceived, response,)%>%
rename(satisE = perceived, satis = response)%>%
inner_join(., wtp_dat,
by = "subject",
keep = FALSE)%>%
rename(wtp = response) %>%
mutate(condition = subject %/% 1000) %>%
mutate(alcohol = if_else((condition%%2)==1, "alcoholic", "non-alcoholic"))%>%
mutate(focus = case_when(condition == 1 ~ 'control',
condition == 2 ~ 'control',
condition == 3 ~ 'hedonic',
condition == 4 ~ 'hedonic',
condition == 5 ~ 'utilitarian',
condition == 6 ~ 'utilitarian'))# gender
total_n <- nrow(data)
males <- data_q%>%filter(gender == "male") %>% nrow()
females <- data_q%>%filter(gender == "female") %>% nrow()
nonbinary <- data_q %>% filter(gender== "non-binary" )%>% nrow()
# by condition
gender_tib <- D1 %>%
filter(measure == "wtp") %>% # avoids duplicating data
group_by( condition) %>%
summarise(n=n(),
BMI = mean(BMI, na.rm = TRUE),
age = mean(age, na.rm = TRUE)) %>%
kable()xtabs(~ gender + condition , data = data_q,drop.unused.levels = TRUE)%>%
kable(digits = 2, caption = "A contingency table with observed gender values/counts across conditions") %>%
kable_styling(full_width = TRUE,
position = "left")| 1 | 2 | 3 | 4 | 5 | 6 | |
|---|---|---|---|---|---|---|
| female | 24 | 21 | 22 | 25 | 30 | 23 |
| male | 6 | 8 | 7 | 6 | 6 | 8 |
| non-binary | 2 | 1 | 1 | 1 | 0 | 0 |
chi_test <- chisq.test(data_q$gender, data_q$condition, simulate.p.value = TRUE)
chi_test$expected %>%
kable(digits = 1, caption = "A contingency table of expected gender values/counts across conditions")%>%
kable_styling(full_width = TRUE,
position = "left")| 1 | 2 | 3 | 4 | 5 | 6 | |
|---|---|---|---|---|---|---|
| female | 24.3 | 22.8 | 22.8 | 24.3 | 27.3 | 23.5 |
| male | 6.9 | 6.4 | 6.4 | 6.9 | 7.7 | 6.7 |
| non-binary | 0.8 | 0.8 | 0.8 | 0.8 | 0.9 | 0.8 |
# χ2 test requires all expected frequencies to be greater than five --> simulate.p.value avoids the problemAltogether 189 participants took part in the study, as is common for psychology studies, most of these were women (145 self-identified as female, 41 as male and 5 as non-binary). The gender split across the conditions was not problematic \(\chi^2\) = 5.28, p = 0.903 (simulated p values based on 2000 replicates, as expected values << 5).
# plot
## bar plot is best here
gender_pal <- c("#d62828", "#003049", "#9d69a3")
gender_cond_plot <-
ggplot(data = data_q)+
geom_bar(aes(x= condition, fill = gender))+
scale_fill_manual(values = gender_pal) +
scale_y_continuous(name="", limits=c(0, 40), breaks = seq(0,40, 5)) +
scale_x_discrete(name = "conditions", breaks = seq(1,6,1), limits = c("1", "2", "3", "4", "5", "6"))+
theme(panel.grid = element_blank())+
theme_minimal()
ggplotly(gender_cond_plot) Number of participants in each conditions
data_desc <- D1 %>%
filter(measure == "wtp")
age_lm <- lm(age ~ condition, data=data_desc)
age_sum <- broom::tidy(age_lm)
age_glance <- broom::glance(age_lm)Participants’ age ranged between 18 and 57. Most participants were very young and the mean age of participants was 20.3 (sd = 4.7). The age did not significantly differ across the six conditions F(181, 1) = 0.26, p = 0.608.
age_plot <- ggplot(data= data_desc, aes(x=condition, y = age, group = condition) )+
geom_boxplot(fill= "#6c757d", alpha = 0.5, outlier.shape = NA) +
geom_jitter(shape=16, position=position_jitter(0.2), aes(color = gender))+
scale_y_continuous(name="age", limits=c(18, 60), breaks = seq(0,60, 10)) +
scale_x_discrete(name = "conditions", limits = c("1", "2", "3", "4", "5", "6"))+
scale_color_manual(values = gender_pal) +
theme_minimal()
age_plot2 <- ggplot(data= data_desc, aes(x=condition, y = age, group = condition) )+
geom_boxplot(fill= "#6c757d", alpha = 0.5, outlier.shape = NA) +
geom_jitter(shape=16, position=position_jitter(0.2), aes(color = gender))+
scale_y_continuous(name="age", limits=c(15, 30), breaks = seq(15,30,5)) +
scale_x_discrete(name = "conditions", limits = c("1", "2", "3", "4", "5", "6"))+
scale_color_manual(values = gender_pal) +
theme_minimal()
ggplotly(age_plot)Participants’ age by condition and gender. Note range of the y-axis
ggplotly(age_plot2)Participants’ age by condition and gender. Note range of the y-axis
bmi_lm <- lm(BMI ~ condition, data=data_desc)
bmi_glance <- broom::glance(bmi_lm)The participants’ BMI ranged between 16.7 - 36.1. The average BMI was 23.1 (sd =3.7) and again, this did not differ across conditions F(186, 1) = 1.62, p = 0.205.
BMI_plot <- ggplot(aes(x=condition, y = BMI), data= data_desc)+
geom_boxplot(fill= "#6c757d", alpha = 0.5) +
geom_jitter(shape=16, position=position_jitter(0.2), aes(color = gender))+
scale_y_continuous(name="BMI", limits=c(18, 35), breaks = seq(0,35, 10)) +
scale_x_discrete(name = "conditions", limits = c("1", "2", "3", "4", "5", "6"))+
scale_color_manual(values = gender_pal) +
theme_minimal()
ggplotly(BMI_plot)Participants’ BMI by condition and gender
Visual inspection of participants’ baseline mood does not give raise to any concerns. Do I need to run 16 anovas? Does not seem necessary…)
mood_base <- D2 %>%
filter(stage == 1)
palette <- c("#033f63","#28666e","#7c9885","#b5b682","#fedc97","#e5e1ee","#c17767","#210203","#eb9486","#82204a", "#0a2342","#2ca58d","#84bc9c","#fffdf7","#f46197","#fec601")
ggplot(data = mood_base, aes(x=condition, y = rating, group = condition, fill = feeling))+
geom_boxplot()+
facet_wrap("feeling")+
scale_fill_manual(values = palette) +
scale_y_continuous(name="", limits=c(0, 100), breaks = seq(0,100, 20)) +
theme(panel.grid = element_blank())+
theme_minimal()Participants’ baseline mood ratings
While the average alcohol consumption was realtively low 10.6 (sd = 8.9), there was a considerable differences among participants. The lowest alcohol consumption was only 1, equivalent to a half a pint of light beer (3.5%) once a week, the highest alcohol consumption was 70 units of alcohol a week, which is equivalent to over 20 pints of strong (~5% abv) beer every week. Interestingly, 45 (23.8%) participants consumed more than the recommended 14 units a week. We also asked participants to estimate how many units of beer they consumed. This was on average 4.8 (sd = 4.7), this however varied between 0 and 30. Thefigures below show participants’ weekly alcohol consumption, weekly beer consumption and the proportion of units of alcohol that came from beer. Neither the overall alcohol consumption nor beer consumption differed significantly across the conditions, F(2, 189) = 3.19, p = 0.069 and F(2, 189) = 0.06, p = 0.804, respectively.
# plot units alcohol consumption by condition
units_plot<-ggplot(aes(x=condition,
y = units,
group = condition),
data= data_q)+
geom_hline(aes(yintercept = 14, linetype = "14 units/week"),
color = "red")+
scale_linetype_manual(name = "max. recommended\nalcohol consumption", values = c(2, 2),
guide = guide_legend(override.aes = list(color = c("red")), title.theme = element_text(size = 8, face = "bold" ) ))+
geom_boxplot(fill= "#6c757d",
alpha = 0.5,
outlier.shape = NA) +
geom_jitter(shape=16,
position=position_jitter(0.2),
aes(color = gender))+
scale_y_continuous(name="alcohol consumption\n(units)",
limits=c(0, 75),
breaks = seq(0,75, 5)) +
scale_x_discrete(name = "conditions",
limits = c("1", "2", "3", "4", "5", "6"))+
scale_color_manual(values = gender_pal) +
theme_minimal()
ggplotly(units_plot)participants’ alcohol consumption by condition
# plot units beer consumption by condition
beer_plot<-ggplot(aes(x=condition,
y = units_beer,
group = condition),
data= data_q)+
geom_boxplot(fill= "#6c757d",
alpha = 0.5,
outlier.shape = NA) +
geom_jitter(shape=16,
position=position_jitter(0.2),
aes(color = gender))+
scale_y_continuous(name="beer consumption\n(units)",
limits=c(0, 35),
breaks = seq(0,35, 5)) +
scale_x_discrete(name = "conditions",
limits = c("1", "2", "3", "4", "5", "6"))+
scale_color_manual(values = gender_pal) +
theme_minimal()
ggplotly(beer_plot)participants’ beer consumption by condition
summary_beer <- data_q %>%
pivot_longer(cols = starts_with("units"), names_to = "al_id", values_to = "units") %>%
mutate(al_id = ifelse(al_id =="units", "all", "beer"))%>%
group_by(condition, al_id)%>%
summarize(units = mean(units))%>%
pivot_wider(names_from = al_id, values_from = units)%>%
mutate(perc= (beer/all)*100)%>%
pivot_longer(cols = c(all, beer), names_to = "alcohol", values_to = "units")
al_pal <- c( "#1d3557","#f4a261")
beer_prop <- ggplot(data=summary_beer,
aes(x=condition,
y=units,
fill = alcohol)) +
geom_bar(stat="identity",
position=position_dodge())+
geom_text(aes(label =paste0(round(perc,1),"%") ),
data = summary_beer %>%filter(alcohol == "beer"),
show.legend = FALSE,
size = 2,
nudge_x = 0.3,
nudge_y = 1,
color = "#1d3557" )+
scale_fill_manual(values = al_pal)+
scale_y_continuous(name="alcohol consumption\n(units)",
limits=c(0, 15),
breaks = seq(0,15, 5)) +
scale_x_discrete(name = "conditions",
limits = c("1", "2", "3", "4", "5", "6"))+
labs( fill = "alcohol")+
theme_minimal()
ggplotly(beer_prop)% of alcohol consumption that is beer by condition
mediation package, function mediate() some resources and documentation
bitter_dat <- D3_dat%>%
dplyr::select(subject, alcohol, focus, condition, bitterE, bitter)
# prep dataset
# model m A --> M
mbm <- lm(bitterE ~ focus + alcohol, data = bitter_dat)
# model A--> B
mby <-lm(bitter ~ bitterE + focus + alcohol, data = bitter_dat)
med_bitter_focus <- mediate(mbm, mby, sims = 1000, boot = FALSE,
boot.ci.type = "perc", treat = "focus", mediator = "bitterE",
control = "control",
conf.level = 0.95, control.value = 0, treat.value = 1)
summary(med_bitter_focus)##
## Causal Mediation Analysis
##
## Quasi-Bayesian Confidence Intervals
##
## Estimate 95% CI Lower 95% CI Upper p-value
## ACME 1.582 0.107 3.86 0.016 *
## ADE 1.713 -5.591 9.53 0.662
## Total Effect 3.295 -4.267 11.36 0.414
## Prop. Mediated 0.256 -4.962 3.59 0.422
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
##
## Sample Size Used: 190
##
##
## Simulations: 1000
med_bitter_alcohol <- mediate(mbm, mby, sims = 1000, boot = FALSE,
boot.ci.type = "perc", treat = "alcohol", mediator = "bitterE",
conf.level = 0.95, control = "alcoholic", control.value = 0, treat.value = 1)
summary(med_bitter_alcohol)##
## Causal Mediation Analysis
##
## Quasi-Bayesian Confidence Intervals
##
## Estimate 95% CI Lower 95% CI Upper p-value
## ACME -0.2224 -1.6937 1.04 0.70
## ADE -0.2298 -5.9452 5.69 0.93
## Total Effect -0.4522 -6.2816 5.74 0.86
## Prop. Mediated 0.0369 -3.5722 2.74 0.87
##
## Sample Size Used: 190
##
##
## Simulations: 1000
refresh_dat <- D3_dat%>%
dplyr::select(subject, alcohol, focus, condition, refreshmentE, refreshment)
# prep dataset
# model m A --> M
mrm <- lm(refreshmentE ~ focus + alcohol, data = refresh_dat)
# model A--> B
mry <-lm(refreshment ~ refreshmentE + focus + alcohol, data = refresh_dat)
med_refreshment_focus <- mediate(mrm, mry, sims = 1000, boot = FALSE,
boot.ci.type = "perc", treat = "focus", mediator = "refreshmentE",
control = "control", conf.level = 0.95, control.value = 0, treat.value = 1)
summary(med_refreshment_focus)##
## Causal Mediation Analysis
##
## Quasi-Bayesian Confidence Intervals
##
## Estimate 95% CI Lower 95% CI Upper p-value
## ACME 0.4571 -1.1353 2.22 0.578
## ADE -5.0189 -10.3972 0.00 0.048 *
## Total Effect -4.5618 -10.0289 0.92 0.092 .
## Prop. Mediated -0.0767 -1.3982 0.97 0.654
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
##
## Sample Size Used: 190
##
##
## Simulations: 1000
plot(med_refreshment_focus)med_refreshment_alcohol <- mediate(mrm, mry, sims = 1000, boot = FALSE,
boot.ci.type = "perc", treat = "alcohol", mediator = "refreshmentE",
conf.level = 0.95, control = "alcoholic", control.value = 0, treat.value = 1)
summary(med_refreshment_alcohol)##
## Causal Mediation Analysis
##
## Quasi-Bayesian Confidence Intervals
##
## Estimate 95% CI Lower 95% CI Upper p-value
## ACME -0.408 -1.844 0.86 0.53
## ADE -1.526 -6.128 2.75 0.50
## Total Effect -1.934 -6.598 2.39 0.43
## Prop. Mediated 0.132 -2.629 2.61 0.61
##
## Sample Size Used: 190
##
##
## Simulations: 1000
plot(med_refreshment_alcohol)liking_dat <- D3_dat%>%
dplyr::select(subject, alcohol, focus, condition, likingE, liking)
# prep dataset
# model m A --> M
mlm <- lm(likingE ~ focus + alcohol, data = liking_dat)
# model A--> B
mly <-lm(liking ~ likingE + focus + alcohol, data = liking_dat)
med_liking_focus <- mediate(mlm, mly, sims = 1000, boot = FALSE,
boot.ci.type = "perc", treat = "focus", mediator = "likingE",
control = "control", conf.level = 0.95, control.value = 0, treat.value = 1)
summary(med_liking_focus)##
## Causal Mediation Analysis
##
## Quasi-Bayesian Confidence Intervals
##
## Estimate 95% CI Lower 95% CI Upper p-value
## ACME -0.757 -2.588 0.30 0.18
## ADE -5.033 -10.857 1.23 0.12
## Total Effect -5.790 -11.628 0.54 0.07 .
## Prop. Mediated 0.104 -0.307 0.94 0.24
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
##
## Sample Size Used: 190
##
##
## Simulations: 1000
plot(med_liking_focus)med_liking_alcohol <- mediate(mlm, mly, sims = 1000, boot = FALSE,
boot.ci.type = "perc", treat = "alcohol", mediator = "likingE",
conf.level = 0.95, control = "alcoholic", control.value = 0, treat.value = 1)
summary(med_liking_alcohol)##
## Causal Mediation Analysis
##
## Quasi-Bayesian Confidence Intervals
##
## Estimate 95% CI Lower 95% CI Upper p-value
## ACME -0.684 -1.997 0.15 0.13
## ADE -3.362 -8.576 1.64 0.20
## Total Effect -4.046 -9.352 1.19 0.13
## Prop. Mediated 0.137 -0.772 1.10 0.24
##
## Sample Size Used: 190
##
##
## Simulations: 1000
plot(med_liking_alcohol)body_dat <- D3_dat%>%
dplyr::select(subject, alcohol, focus, condition, bodyE, body)
# prep dataset
# model m A --> M
mbom <- lm(bodyE ~ focus + alcohol, data = body_dat)
# model A--> B
mboy <-lm(body ~ bodyE + focus + alcohol, data = body_dat)
med_body_focus <- mediate(mbom, mboy, sims = 1000, boot = FALSE,
boot.ci.type = "perc", treat = "focus", mediator = "bodyE",
control = "control", conf.level = 0.95, control.value = 0, treat.value = 1)
summary(med_body_focus)##
## Causal Mediation Analysis
##
## Quasi-Bayesian Confidence Intervals
##
## Estimate 95% CI Lower 95% CI Upper p-value
## ACME 1.002 -0.243 2.82 0.11
## ADE 1.334 -5.442 8.26 0.71
## Total Effect 2.336 -4.877 8.99 0.53
## Prop. Mediated 0.173 -3.765 3.74 0.55
##
## Sample Size Used: 190
##
##
## Simulations: 1000
plot(med_body_focus)med_body_alcohol <- mediate(mbom, mboy, sims = 1000, boot = FALSE,
boot.ci.type = "perc", treat = "alcohol", mediator = "bodyE",
conf.level = 0.95, control = "alcoholic", control.value = 0, treat.value = 1)
summary(med_body_alcohol)##
## Causal Mediation Analysis
##
## Quasi-Bayesian Confidence Intervals
##
## Estimate 95% CI Lower 95% CI Upper p-value
## ACME -0.8392 -2.2810 0.15 0.116
## ADE -6.2253 -11.8754 -0.51 0.032 *
## Total Effect -7.0646 -12.7177 -1.49 0.012 *
## Prop. Mediated 0.1078 -0.0301 0.60 0.124
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
##
## Sample Size Used: 190
##
##
## Simulations: 1000
plot(med_body_alcohol)# model m A --> M
msm <- lm(satisE ~ focus + alcohol, data = satis_dat)
# model A--> B
msy <-lm(satis ~ satisE + focus + alcohol, data = satis_dat)
med_satis_focus <- mediate(msm, msy, sims = 1000, boot = FALSE,
boot.ci.type = "perc", treat = "focus", mediator = "satisE",
control = "control", conf.level = 0.95, control.value = 0, treat.value = 1)
summary(med_satis_focus)##
## Causal Mediation Analysis
##
## Quasi-Bayesian Confidence Intervals
##
## Estimate 95% CI Lower 95% CI Upper p-value
## ACME 0.2320 -0.9267 1.74 0.67
## ADE -4.6094 -11.3833 1.94 0.18
## Total Effect -4.3774 -11.1578 2.09 0.20
## Prop. Mediated -0.0259 -1.2339 0.87 0.76
##
## Sample Size Used: 187
##
##
## Simulations: 1000
plot(med_satis_focus)med_satis_alcohol <- mediate(msm, msy, sims = 1000, boot = FALSE,
boot.ci.type = "perc", treat = "alcohol", mediator = "satisE",
conf.level = 0.95, control = "alcoholic", control.value = 0, treat.value = 1)
summary(med_satis_alcohol)##
## Causal Mediation Analysis
##
## Quasi-Bayesian Confidence Intervals
##
## Estimate 95% CI Lower 95% CI Upper p-value
## ACME -0.7128 -2.1351 0.19 0.132
## ADE -6.9634 -12.7137 -1.38 0.016 *
## Total Effect -7.6763 -13.5267 -1.84 0.006 **
## Prop. Mediated 0.0805 -0.0300 0.40 0.134
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
##
## Sample Size Used: 187
##
##
## Simulations: 1000
plot(med_satis_alcohol)There was an effect of alcohol content on expected and perceived satisfaction. Participants rated their expected and perceived satisfaction lower when they drank non-alcoholic beer. We, however did not observe a mediation effect. (potentially small effect size, given the pp sample)
** more detail needed here **
# model m A --> M
mwm <- lm(satis ~ focus + alcohol, data = satis_dat)
# model A--> B
mwy <-lm(wtp ~ satis + focus + alcohol, data = satis_dat)
med_wtp_focus <- mediate(mwm, mwy, sims = 1000, boot = FALSE,
boot.ci.type = "perc", treat = "focus", mediator = "satis",
control = "control", conf.level = 0.95, control.value = 0, treat.value = 1)
summary(med_wtp_focus)##
## Causal Mediation Analysis
##
## Quasi-Bayesian Confidence Intervals
##
## Estimate 95% CI Lower 95% CI Upper p-value
## ACME -0.0891 -0.2356 0.05 0.20
## ADE -0.0725 -0.3417 0.21 0.59
## Total Effect -0.1616 -0.4756 0.14 0.30
## Prop. Mediated 0.4147 -3.3107 4.76 0.34
##
## Sample Size Used: 187
##
##
## Simulations: 1000
plot(med_wtp_focus)med_wtp_alcohol <- mediate(mwm, mwy, sims = 1000, boot = FALSE,
boot.ci.type = "perc", treat = "alcohol", mediator = "satis",
conf.level = 0.95, control = "alcoholic", control.value = 0, treat.value = 1)
summary(med_wtp_alcohol)##
## Causal Mediation Analysis
##
## Quasi-Bayesian Confidence Intervals
##
## Estimate 95% CI Lower 95% CI Upper p-value
## ACME -0.1555 -0.2800 -0.04 0.012 *
## ADE -0.0998 -0.3277 0.14 0.388
## Total Effect -0.2552 -0.5172 0.00 0.056 .
## Prop. Mediated 0.5812 -0.4462 3.04 0.060 .
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
##
## Sample Size Used: 187
##
##
## Simulations: 1000
plot(med_wtp_alcohol)wtp_model <- robust::lmRob(wtp ~ focus + alcohol, data = satis_dat)
summary(wtp_model)##
## Call:
## robust::lmRob(formula = wtp ~ focus + alcohol, data = satis_dat)
##
## Residuals:
## Min 1Q Median 3Q Max
## -2.07412 -0.81824 0.09272 0.92588 2.12384
##
## Coefficients:
## Estimate Std. Error t value Pr(>|t|)
## (Intercept) 3.0741 0.1667 18.445 <2e-16 ***
## focushedonic -0.1668 0.2032 -0.821 0.413
## focusutilitarian -0.1980 0.2022 -0.979 0.329
## alcoholnon-alcoholic -0.2559 0.1661 -1.540 0.125
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
##
## Residual standard error: 0.8919 on 183 degrees of freedom
## Multiple R-Squared: 0.02964
##
## Test for Bias:
## statistic p-value
## M-estimate 16.18 0.002792
## LS-estimate -3.82 1.000000
wtp_tib <- satis_dat %>%
group_by(focus, alcohol) %>%
summarise(n = n(),
mean_wtp = mean(wtp, na.rm = TRUE),
sd_wtp = sd(wtp, na.rm = TRUE),
ci_lo = mean_wtp - 1.96 * (sd_wtp/sqrt(n)),
ci_high = mean_wtp + 1.96 *(sd_wtp/sqrt(n)))
wtp_tib %>%
kable(digits = 2, caption = "Participants' mean willingness to pay in different alcohol and focus conditions.") %>%
kable_styling(full_width = TRUE)| focus | alcohol | n | mean_wtp | sd_wtp | ci_lo | ci_high |
|---|---|---|---|---|---|---|
| control | alcoholic | 30 | 3.13 | 0.90 | 2.81 | 3.46 |
| control | non-alcoholic | 30 | 2.73 | 0.83 | 2.44 | 3.03 |
| hedonic | alcoholic | 28 | 2.89 | 0.88 | 2.57 | 3.22 |
| hedonic | non-alcoholic | 32 | 2.66 | 0.97 | 2.32 | 2.99 |
| utilitarian | alcoholic | 37 | 2.84 | 0.73 | 2.60 | 3.07 |
| utilitarian | non-alcoholic | 30 | 2.70 | 0.88 | 2.39 | 3.01 |
wtp_bar <-ggplot(aes(x=focus,
y = mean_wtp,
fill = alcohol),
data= wtp_tib)+
geom_bar(stat="identity", position=position_dodge())+
geom_errorbar(aes(ymin=ci_lo, ymax=ci_high), width=.2,
position=position_dodge(.9))+
scale_y_continuous(name="willingness to pay (£)",
limits=c(0, 5),
breaks = seq(0,5, 1)) +
scale_x_discrete(name = "focus" )+
scale_fill_manual(values = gender_pal) +
theme_minimal()Participants’ cognitive performance was assessed using the inspection time task () which measures participants’information processing. Participants completed the task just before, 30 minutes and 60 minutes after consumption. The data was analysed using a growth curve analysis.
# these are two methods of analysis, should do the same thing, buttakes too long to run
# m_itt <- lmerTest::lmer(correct ~ focus * alcohol *stage *stimulus + (stage*stimulus| subject), data=itt_dat, REML=F)
#
# summary(m_itt)
# contrasts
itt_afx <- afex::aov_4(correct ~ focus*alcohol*stage*stimulus + (stimulus*stage|subject), data = itt_dat)
# need to take effects apart and set contrasts
# the main effect of alcohol
alcohol_emm <- emmeans::emmeans(itt_afx, ~alcohol, model = "multivariate")
alcohol_emm # shows us the means## alcohol emmean SE df lower.CL upper.CL
## alcoholic 0.887 0.00777 178 0.872 0.903
## non-alcoholic 0.919 0.00783 178 0.903 0.934
##
## Results are averaged over the levels of: focus, stage, stimulus
## Confidence level used: 0.95
# the main effect of stage
stage_emm <- emmeans::emmeans(itt_afx, ~stage, model = "multivariate")
stage_emm## stage emmean SE df lower.CL upper.CL
## stage.1 0.909 0.00632 178 0.896 0.921
## stage.2 0.908 0.00553 178 0.897 0.919
## stage.3 0.892 0.00637 178 0.879 0.904
##
## Results are averaged over the levels of: focus, alcohol, stimulus
## Confidence level used: 0.95
emmeans::contrast(stage_emm, method = "trt.vs.ctrl", ref = 1, adjust = "holm")## contrast estimate SE df t.ratio p.value
## stage.2 - stage.1 -0.000635 0.00473 178 -0.134 0.8933
## stage.3 - stage.1 -0.017376 0.00543 178 -3.198 0.0033
##
## Results are averaged over the levels of: focus, alcohol, stimulus
## P value adjustment: holm method for 2 tests
#main effect of stimulus
stimulus_emm <- emmeans::emmeans(itt_afx, ~stimulus, model = "multivariate")
stimulus_emm## stimulus emmean SE df lower.CL upper.CL
## stim1 0.701 0.00747 178 0.686 0.716
## stim2 0.846 0.00784 178 0.830 0.861
## stim3 0.857 0.00733 178 0.843 0.871
## stim4 0.862 0.00770 178 0.846 0.877
## stim5 0.921 0.00682 178 0.908 0.934
## stim6 0.924 0.00623 178 0.911 0.936
## stim7 0.934 0.00610 178 0.922 0.946
## stim8 0.944 0.00574 178 0.933 0.955
## stim9 0.945 0.00586 178 0.934 0.957
## stim10 0.948 0.00586 178 0.936 0.959
## stim11 0.947 0.00597 178 0.935 0.959
## stim12 0.954 0.00550 178 0.943 0.965
## stim13 0.956 0.00566 178 0.945 0.967
##
## Results are averaged over the levels of: focus, alcohol, stage
## Confidence level used: 0.95
emmeans::contrast(stimulus_emm, method = "poly", adjust = "holm")## contrast estimate SE df t.ratio p.value
## linear 2.76 0.0932 178 29.566 <.0001
## quadratic -5.21 0.1856 178 -28.062 <.0001
## cubic 1.32 0.0952 178 13.873 <.0001
## quartic -7.12 0.9739 178 -7.307 <.0001
## degree 5 2.40 0.2484 178 9.660 <.0001
## degree 6 -3.96 0.3900 178 -10.149 <.0001
##
## Results are averaged over the levels of: focus, alcohol, stage
## P value adjustment: holm method for 6 tests
# interaction stimulus:stage
inter_emm <- emmeans::emmeans(itt_afx, c("stage", "stimulus"), model = "multivariate")
inter_emm## stage stimulus emmean SE df lower.CL upper.CL
## stage.1 stim1 0.672 0.01041 178 0.652 0.693
## stage.2 stim1 0.716 0.01077 178 0.695 0.738
## stage.3 stim1 0.715 0.01037 178 0.694 0.735
## stage.1 stim2 0.863 0.00923 178 0.844 0.881
## stage.2 stim2 0.847 0.00921 178 0.829 0.865
## stage.3 stim2 0.828 0.00976 178 0.809 0.847
## stage.1 stim3 0.865 0.00876 178 0.848 0.883
## stage.2 stim3 0.870 0.00889 178 0.852 0.887
## stage.3 stim3 0.836 0.00896 178 0.818 0.854
## stage.1 stim4 0.881 0.00909 178 0.863 0.899
## stage.2 stim4 0.855 0.00907 178 0.837 0.873
## stage.3 stim4 0.849 0.00973 178 0.830 0.868
## stage.1 stim5 0.924 0.00835 178 0.907 0.940
## stage.2 stim5 0.928 0.00749 178 0.914 0.943
## stage.3 stim5 0.911 0.00841 178 0.894 0.927
## stage.1 stim6 0.936 0.00682 178 0.922 0.949
## stage.2 stim6 0.928 0.00727 178 0.914 0.943
## stage.3 stim6 0.907 0.00783 178 0.891 0.922
## stage.1 stim7 0.941 0.00780 178 0.925 0.956
## stage.2 stim7 0.937 0.00638 178 0.924 0.949
## stage.3 stim7 0.926 0.00749 178 0.911 0.940
## stage.1 stim8 0.951 0.00750 178 0.936 0.966
## stage.2 stim8 0.948 0.00575 178 0.937 0.959
## stage.3 stim8 0.932 0.00814 178 0.916 0.948
## stage.1 stim9 0.951 0.00758 178 0.936 0.966
## stage.2 stim9 0.953 0.00625 178 0.941 0.965
## stage.3 stim9 0.932 0.00689 178 0.919 0.946
## stage.1 stim10 0.956 0.00723 178 0.941 0.970
## stage.2 stim10 0.955 0.00653 178 0.942 0.968
## stage.3 stim10 0.932 0.00727 178 0.918 0.947
## stage.1 stim11 0.952 0.00783 178 0.937 0.968
## stage.2 stim11 0.953 0.00610 178 0.941 0.965
## stage.3 stim11 0.936 0.00765 178 0.921 0.952
## stage.1 stim12 0.963 0.00717 178 0.949 0.977
## stage.2 stim12 0.955 0.00566 178 0.944 0.966
## stage.3 stim12 0.943 0.00713 178 0.929 0.957
## stage.1 stim13 0.962 0.00665 178 0.949 0.975
## stage.2 stim13 0.962 0.00626 178 0.950 0.974
## stage.3 stim13 0.944 0.00715 178 0.930 0.958
##
## Results are averaged over the levels of: focus, alcohol
## Confidence level used: 0.95
emmeans::contrast(
inter_emm,
c(stage = "trt.vs.ctrl", stimulus = "poly"),
rel = 1,
adjust = "holm"
)## contrast estimate SE df t.ratio p.value
## stage.2 stim1 - stage.1 stim1 0.0439 0.0135 178 3.257 0.0027
## stage.3 stim1 - stage.1 stim1 0.0421 0.0137 178 3.079 0.0027
## stage.1 stim2 - stage.1 stim1 0.1902 0.0106 178 18.003 <.0001
## stage.2 stim2 - stage.1 stim1 0.1742 0.0116 178 15.007 <.0001
## stage.3 stim2 - stage.1 stim1 0.1557 0.0117 178 13.329 <.0001
## stage.1 stim3 - stage.1 stim1 0.1930 0.0101 178 19.207 <.0001
## stage.2 stim3 - stage.1 stim1 0.1973 0.0104 178 18.880 <.0001
## stage.3 stim3 - stage.1 stim1 0.1634 0.0111 178 14.660 <.0001
## stage.1 stim4 - stage.1 stim1 0.2082 0.0110 178 18.840 <.0001
## stage.2 stim4 - stage.1 stim1 0.1829 0.0113 178 16.166 <.0001
## stage.3 stim4 - stage.1 stim1 0.1763 0.0119 178 14.801 <.0001
## stage.1 stim5 - stage.1 stim1 0.2515 0.0110 178 22.820 <.0001
## stage.2 stim5 - stage.1 stim1 0.2560 0.0112 178 22.949 <.0001
## stage.3 stim5 - stage.1 stim1 0.2382 0.0109 178 21.847 <.0001
## stage.1 stim6 - stage.1 stim1 0.2634 0.0106 178 24.888 <.0001
## stage.2 stim6 - stage.1 stim1 0.2560 0.0113 178 22.664 <.0001
## stage.3 stim6 - stage.1 stim1 0.2344 0.0114 178 20.518 <.0001
## stage.1 stim7 - stage.1 stim1 0.2682 0.0107 178 24.987 <.0001
## stage.2 stim7 - stage.1 stim1 0.2641 0.0105 178 25.037 <.0001
## stage.3 stim7 - stage.1 stim1 0.2531 0.0112 178 22.671 <.0001
## stage.1 stim8 - stage.1 stim1 0.2786 0.0108 178 25.780 <.0001
## stage.2 stim8 - stage.1 stim1 0.2756 0.0102 178 26.988 <.0001
## stage.3 stim8 - stage.1 stim1 0.2599 0.0116 178 22.321 <.0001
## stage.1 stim9 - stage.1 stim1 0.2784 0.0110 178 25.341 <.0001
## stage.2 stim9 - stage.1 stim1 0.2806 0.0111 178 25.329 <.0001
## stage.3 stim9 - stage.1 stim1 0.2598 0.0111 178 23.461 <.0001
## stage.1 stim10 - stage.1 stim1 0.2832 0.0110 178 25.756 <.0001
## stage.2 stim10 - stage.1 stim1 0.2827 0.0106 178 26.659 <.0001
## stage.3 stim10 - stage.1 stim1 0.2598 0.0117 178 22.153 <.0001
## stage.1 stim11 - stage.1 stim1 0.2798 0.0114 178 24.602 <.0001
## stage.2 stim11 - stage.1 stim1 0.2806 0.0108 178 25.919 <.0001
## stage.3 stim11 - stage.1 stim1 0.2640 0.0117 178 22.576 <.0001
## stage.1 stim12 - stage.1 stim1 0.2907 0.0109 178 26.560 <.0001
## stage.2 stim12 - stage.1 stim1 0.2828 0.0112 178 25.360 <.0001
## stage.3 stim12 - stage.1 stim1 0.2706 0.0117 178 23.037 <.0001
## stage.1 stim13 - stage.1 stim1 0.2892 0.0108 178 26.842 <.0001
## stage.2 stim13 - stage.1 stim1 0.2896 0.0109 178 26.655 <.0001
## stage.3 stim13 - stage.1 stim1 0.2714 0.0115 178 23.677 <.0001
##
## Results are averaged over the levels of: focus, alcohol
## P value adjustment: holm method for 38 tests
itt_dat$stimulus <- as.factor(itt_dat$stimulus) %>%
fct_relevel(.,c("stim1", "stim2", "stim3", "stim4", "stim5", "stim6", "stim7", "stim8", "stim9", "stim10", "stim11", "stim12","stim13"))
ggplot(data = itt_dat, aes(x = stimulus, y = correct, color = alcohol))+
facet_grid(rows = vars(focus),
cols = vars(stage))+
stat_summary(fun=mean, geom="point") +
scale_y_continuous(name="% correct", limits=c(0.5, 1.0), breaks = seq(0.5,1,0.15)) +
scale_x_discrete(name = "stimulus duration\n(ms)", labels =c("19", "25", "31", "37", "44", "50", "62", "75", "87", "100", "125", "150", "200") )+
scale_color_manual(values = gender_pal) +
theme(axis.text.x = element_text( color="black",
size=6, angle=45))+
theme_minimal()Participants’ cognitive performance